package com.leyou.page.handle;

import com.leyou.page.Service.PageService;
import com.leyou.page.entity.Sku;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import top.javatool.canal.client.annotation.CanalTable;
import top.javatool.canal.client.handler.EntryHandler;
@CanalTable(value = "tb_sku")
@Component
public class SkuHandle implements EntryHandler<Sku> {
    @Autowired
    private PageService pageService;
    @Override
    public void insert(Sku sku) {
        //增加，则去tomcat中查询
        pageService.querySkuById(sku.getSpuId());
    }

    @Override
    public void update(Sku before, Sku after) {
        //更改，也去tomcat中查询，然后覆盖
        pageService.querySkuById(after.getSpuId());
    }

    @Override
    public void delete(Sku sku) {
        //删除，则从redis中删除
        pageService.deleteSkuFromRedis(sku.getId(),sku.getSpuId());
    }
}
